package cn.com.taiji.oospub.wechat.service.impl;

import cn.com.taiji.oospub.wechat.entity.RushTimeForecast;
import cn.com.taiji.oospub.wechat.mapper.RushTimeForecastMapper;
import cn.com.taiji.oospub.wechat.service.IRushTimeForecastService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 
 * @since 2020-10-28
 */
@Service
public class RushTimeForecastServiceImpl extends ServiceImpl<RushTimeForecastMapper, RushTimeForecast> implements IRushTimeForecastService {
    @Autowired
    private RushTimeForecastMapper rushTimeForecastMapper;

    @Override
    public RushTimeForecast findByProperty(String columnName, String value) {
        HashMap<String, Object> columnMap = new HashMap<>();
        columnMap.put(columnName, value);
        List<RushTimeForecast> rushTimeForecasts = rushTimeForecastMapper.selectByMap(columnMap);
        if (rushTimeForecasts.size() > 0){
            return rushTimeForecasts.get(0);
        }
        return null;
    }

    @Override
    public IPage<RushTimeForecast> queryPage(Page<RushTimeForecast> page, QueryWrapper<RushTimeForecast> queryModel) {
        page.addOrder(OrderItem.asc("id"));
        return rushTimeForecastMapper.selectPage(page, queryModel);
    }

    @Override
    public RushTimeForecast findById(String id) {
        return rushTimeForecastMapper.selectById(id);
    }
}
